import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';

import { renderDict, renderDictTag } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'alarmName',
    label: '名称',
  },
];

export const columns: VxeGridProps['columns'] = [
  {
    title: '名称',
    field: 'alarmName',
  },
  {
    title: '描述',
    field: 'alarmDesc',
  },
  {
    title: '启用状态',
    field: 'enabled',
    slots: {
      default: ({ row }) => {
        return renderDictTag(`${row.enabled}`, [
          {
            dictLabel: '禁用',
            dictValue: '0',
            listClass: 'danger',
          },
          {
            dictLabel: '启用',
            dictValue: '1',
            listClass: 'success',
          },
        ]);
      },
    },
  },
  {
    title: '告警级别',
    field: 'level',
    slots: {
      default: ({ row }) => {
        return renderDict(row.level, DictEnum.IOT_ALARM_LEVEL_TYPE);
      },
    },
  },
  {
    title: '创建时间',
    field: 'createTime',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
  },
];
